package zerous.dodgestones.screen;

import com.badlogic.gdx.*;
import com.badlogic.gdx.scenes.scene2d.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.graphics.g2d.*;
import zerous.dodgestones.*;
import com.badlogic.gdx.scenes.scene2d.utils.*;

public class MainScreen extends ScreenAdapter
{
	Traveler game;
	Stage stage;
	Button startButton, highScore;
	public MainScreen(Traveler game) {
		this.game = game;
	}

	@Override
	public void show() {
		// TODO: Implement this method
		super.show();
		stage = new Stage();
		Sprite t = new Sprite(Traveler.START);
		Sprite tt = new Sprite(Traveler.HIGH_SCORE);
		Util.setupSprite(tt, Info.PIXEL_SIZE);
		Util.setupSprite(t, Info.PIXEL_SIZE);
		startButton = new Button(new SpriteDrawable(t));
		highScore = new Button(new SpriteDrawable(tt));
		startButton.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent e, float x, float y) {
				game.setScreen(game.gameScreen);
			}
		});
		highScore.addListener(new ClickListener() {
				@Override
				public void clicked(InputEvent e, float x, float y) {
					
				}
			});
		startButton.setPosition(Gdx.graphics.getWidth()/2 - startButton.getWidth()/2, Gdx.graphics.getHeight()/2 - startButton.getHeight()/2);
		highScore.setPosition(startButton.getX(), startButton.getY() - tt.getHeight() - 5 * Info.PIXEL_SIZE);
		stage.addActor(startButton);
		stage.addActor(highScore);
		Gdx.input.setInputProcessor(stage);
	}

	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0.1f, 0.1f, 0.5f, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		
		stage.act();
		stage.draw();
	}
}

